define(
   [
      'dojo/_base/declare',
      'dojo/_base/lang'
   ],
   function(declare, lang)
   {
      return declare([],
      {
         constructor:function(args)
         {
            dojo.safeMixin(this, args);
         },
         postscript: function(args)
         {
            this.inherited(arguments);
            if(!this.mResources || !this.mResources instanceof Object)
            {
               console.error('Resources must be defined as name keyed object.');
               return;
            }
         },
         expand: function(resourceName, keyName, replacements)
         {
            if(!this.mResources[resourceName])
            {
               console.error("Resource name \""+resourceName+"\" not found.");
               return "";
            }
            
            var str = this.mResources[resourceName][keyName];
            if(!str)
            {
               console.error("Key \""+keyName+"\" not found in resource named \""+resourceName+"\".");
               return "";
            }

            console.log("Original string: " + str);
            for(var i in replacements)
               str = str.replace("%%" + i + "%%", replacements[i]);
            console.log("Final string: " + str);
            
            return str;
         }
      });
   }
);
